function [ img ] = normalize( img, max_val , cut_negative )
%NORMALIZE an image by translation and scaling to 

if(nargin<3)
    cut_negative=false;
end
if(nargin<2)
    max_val=1;
end

if(cut_negative)
    img(img==0)=0;
end


imSize=size(img);
mini=min(img(:));
img=img - mini.*ones(imSize);
maxi=max(img(:));
img=img/maxi;


end

